#pragma once

#include <d3d9.h>
#include <d3dx9.h>
#include <dinput.h>
#pragma comment(lib, "d3d9.lib")
#pragma comment(lib, "dinput8.lib")
#pragma comment(lib, "dxguid.lib")
#pragma comment(lib, "d3dx9.lib")
#pragma comment(lib, "winmm.lib")

//#include "fmod.hpp"
//#pragma comment(lib, "fmodex_vc.lib")

// Macro to release COM objects fast and safely
#define SAFE_RELEASE(x) if(x){x->Release(); x = 0;}


class Framework
{
	//////////////////////////////////////////////////////////////////////////
	// DirectX Variables
	//////////////////////////////////////////////////////////////////////////
	HWND				m_hWnd;			//Handle

	bool				m_bVsync;		//Vertical sync

	IDirect3D9*			m_pD3DObject;	//Direct3D object

	IDirect3DDevice9*	m_pD3DDevice;	//Direct3D device

	D3DCAPS9			m_D3DCaps;		//Direct3D capabilities

	ID3DXFont*			m_pD3DFont;		//Font

	ID3DXSprite*		m_pD3DSprite;	//Sprite

	LPDIRECTINPUT8		m_pDirectInput; //Direct Input device

	LPDIRECTINPUTDEVICE8 m_pInKeyboard; //Keyboard device
	
	LPDIRECTINPUTDEVICE8 m_pInMouse;	//Mouse device

	DIMOUSESTATE		m_pMouseState;	//Mouse information storage

	IDirect3DTexture9*	m_pTexture[3];	//Textures

	D3DXIMAGE_INFO		m_imageInfo;	//Texture info


	//////////////////////////////////////////////////////////////////////////
	// FMOD Variables
	//////////////////////////////////////////////////////////////////////////
	/*FMOD_RESULT result;

	FMOD::System *system;

	FMOD::Sound* sound;

	FMOD::Channel* channel[2];

	FMOD::Sound* stream;*/


	//////////////////////////////////////////////////////////////////////////
	// WinSock Variables
	//////////////////////////////////////////////////////////////////////////
	WSADATA wsaData;
	SOCKET 	Socket;

	int retval;			//Return value for recv function
	char buffer[1];	//Buffer for character sent / received
	

	//////////////////////////////////////////////////////////////////////////
	// Game-related Variables
	//////////////////////////////////////////////////////////////////////////

	float m_pDt,		//Delta time
		timeElapsed;				

	bool once;

	struct vec2
	{
		vec2(){x = 0.0f; y = 0.0f;}; //Default constructor
		vec2(float a, float b){x = a; y = b;}; //Parameterized

		float x, y;

	};

	vec2 selection,
		current_position,
		last_position,
		delta_position,
		cursor_position,
		sector_area[64];

	POINT pt;

	char map;			//Map currently displayed to user (G or Q)
	int button_index;	//Holds the index of button clicked


public:
	bool click;


public:
	//////////////////////////////////////////////////////////////////////////
	// Framework Functions
	//////////////////////////////////////////////////////////////////////////

	Framework();

	~Framework();

	void Init(HWND& hWnd, HINSTANCE& hInst, bool bWindowed);

	void Update(float dt);

	void Render();

	void RunClient();

	void Shutdown();

};